<?php
/**
 * Created by PhpStorm.
 * User: mac
 * Date: 2019-03-02
 * Time: 01:03
 */

class mysql
{
    public $db = null;
    public $config = array();

    public function __construct()
    {
        $this->db = new swoole_mysql();
        $this->config = array(
            'host' => '127.0.0.1',
            'port' => 3306,
            'user' => 'root',
            'password' => '',
            'databases' => 'swoole',
            'charset' => 'utf8'
        );
    }

    public function exec()
    {
        $this->db->connect($this->config, function ($db, $r) {
            if ($r == false) {
                echo 'connect err ' . PHP_EOL;
                exit();
            }

            $sql = 'inset into news values (null, )';
        });
    }
}